import {GlobelConfig} from '@localModules/ZhiXinLib/element-components/dynamic-form/ConfigType'
import RenderUtils from "@localModules/ZhiXinLib/element-components/dynamic-form/RenderUtils";

GlobelConfig.externalComponents = [
  {
    name: 'ElInputTest',
    components: {
      ElInputTest: () => import('element-ui').then(res => res.Input)
    },
    /**
     * 渲染函数
     * @param createElement
     * @param vm
     * @param formItem {FormItem}
     * @return {VNode[]}
     */
    render(createElement, vm, formItem) {
      return [
        createElement('ElInputTest',{
          ref: RenderUtils.formItemToRef(formItem),
          refInFor: true,
          props: {
            ...formItem?.props,
            disabled: RenderUtils.setDisabled(formItem, vm) // 增强disabled
          },
          attrs: {
            placeholder: formItem?.props?.placeholder || '请输入' + formItem.label,
            maxlength: formItem?.props?.maxlength || null,
            minlength: formItem?.props?.minlength || null,
            max: formItem?.props?.max || null,
            min: formItem?.props?.min || null,
          },
          model: RenderUtils.getModelConfig(vm, formItem),
          on: {
            ...formItem.events,
          },
        })
      ]
    }
  }
]
